-- UISkyCityIslandInfo
-- Create By Cheny3 Dec/22/2015
-- 浮岛详细页

-- UISkyCityIslandInfo继承自Layer
UISkyCityIslandInfo = class("UISkyCityIslandInfo", function()
    return cc.Layer:create();
end);

function UISkyCityIslandInfo.create(info)
    return UISkyCityIslandInfo.new(info);
end

-- 内部函数声明
local offsetY = 0;
local fixWidth = 0;

-- 奖励格最大行数和列数
local MAX_GRID_ROW    = 2;
local MIN_GRID_COLUMN = 4;

-- 浮岛资源路径
local SKY_ISLAND_RES_PATH = "images/ui/sky_city/sky_island/";

-- 构造函数
function UISkyCityIslandInfo:ctor(info)
    -- 初始化
    self:setName("UISkyCityIslandInfo");
    -- 复用飞艇信息页面
    local node = cc.CSLoader:createNode("layout/sky_city/IslandInfo.csb");
    self:addChild(node);
    self.node = node;

    -- 详细信息
    self.info = info;

    local bonusNode = findChildByName(self.node, "BT2/desc_node/bonus_node");
    self.scrollView = findChildByName(bonusNode, "bonus_panel");

    -- 重绘
    self:redraw();

    -- 注册事件处理回调函数
    self:registerEventCallback();

    -- 注册点击事件
    self:registerTouchEvent();

    -- 播放信息出现效果
    local detailNode = findChildByName(self.node, "CT/detail_node");
    playAirShipInfoEffect(detailNode);

    -- 播放准心特效
    -- local reticleNode = findChildByName(self.node, "CT/reticle_node");
    playReticleEffect(self.node);

    -- 标题和描述在中间浮现
    self:comformCenterEffect();

    -- 适配
    self:resize();
end

-- 分析浮岛信息
function UISkyCityIslandInfo:initData()
    local info = table.deepcopy(self.info);
    local eventId = info.id;
    local eventConfig = SkyExploreM.query(eventId);
    local combat_dbase = eventConfig["combat_dbase"] or {};

    -- 标题
    local title = eventConfig["name"];

    -- 四维信息
    local ability = table.deepcopy(eventConfig["combat_dbase"]);
    local attribList = {"fire", "armor", "speed", "luck"};
    if eventConfig["rule"] ~= "player" then
        for _, attrib in pairs(attribList) do
            -- 修正
            ability[attrib] = FormulaM.invoke("CALC_SKY_MONSTER_INIT_ATTRIB",
                eventId, info.explore_level, ability[attrib]);
        end
    end

    -- 总战力
    local fightAbility = FormulaM.invoke("CALC_SKY_MONSTER_FIGHT_ABILITY", eventId, info.explore_level, combat_dbase["ability_fix"]);

    -- 图标
    local icon = SkyExploreM.query(eventId, "icon");
    local iconPath = getSkyCityIslandIconPath(icon);

    -- 如果是玩家信息
    if eventConfig["rule"] == "player" then
        -- 玩家昵称
        title = info["enemy"].name;
        -- 四维信息
        ability = {
            ["fire"]  = info["enemy"].fire,
            ["armor"] = info["enemy"].armor,
            ["speed"] = info["enemy"].speed,
            ["luck"]  = info["enemy"].luck,
            ["fight_ability"] = info["enemy"].fight_ability,
        };

        local data = table.deepcopy(info["enemy"]);

        local attribs = {"fire", "luck", "speed", "armor", "fight_ability"};

        local skyProp = info["enemy"]["sky_prop"] or {};
        for _, attrib in ipairs(attribs) do
            local addon = SkyPropM.calcAddonByData({["sky_prop"] = skyProp}, attrib, ability[attrib]);
            ability[attrib] = ability[attrib] + addon;
        end

        -- 冈布奥数量
        local petsList = info["enemy"].pets;
        ability["slime"] = #(petsList);
        ability["camp"] = CampM.getPetCamp(petsList[1]);

        -- 总战力
        fightAbility = ability.fight_ability;

        -- 图标（玩家飞船）
        iconPath = getAirShipImgPath(NewAirShipM.query(info["enemy"].ship_id, "icon"));
    end

    -- 计算奖励描述
    local bonus = FormulaM.invoke("CALC_SKY_EVENT_BONUS", eventId, info.explore_level);

    local data = {};
    data = {
        ["title"]    = getNickName(title),
        ["rule"]     = eventConfig["rule"],
        ["icon"]     = iconPath,
        ["iconName"] = icon,
        ["ability"]  = ability,
        ["fightAbility"] = fightAbility,
        ["bonus"]    = bonus,
    };
    return data;
end

-- 适配
function UISkyCityIslandInfo:resize()
    local node = self.node;

    -- bg居中显示并充满整个屏幕
    AlignM.fitToScreen(node, "bg");
    AlignM.fitToScreen(node, "bg2");

    -- CT居中并缩放至合适大小
    AlignM.alignToCenter(node, "CT");

    AlignM.alignToTopCenter(node, "Top");

    -- BT置于底部并缩放至合适大小
    AlignM.alignToBottomCenter(node, "BT");
    AlignM.alignToBottomCenter(node, "BT2");
end

-- 重绘界面
function UISkyCityIslandInfo:redraw()
    -- 构造分析浮岛详细信息
    local data = self:initData();
    self.data = data;

    -- 上调位置节点
    local moveNodes = {};

    -- 显示标题
    local titleLabel = findChildByName(self.node, "Top/title/text");
    titleLabel:setString(data.title);

    if data.rule ~= "player" then
        TextStyleM.setArtWordTitleStyle(titleLabel);
    else
        -- 玩家使用系统字
        titleLabel:setFontSize(TextStyleM.TEXT_SIZE_MIDDLE);
        titleLabel:setTextColor(TextStyleM.TEXT_COLOR_BROWN_YELLOW);
    end

    -- 绘制图标
    local icon = findChildByName(self.node, "CT/airship");
    if data.rule == "player" then
        createAirShip(icon, self.info["enemy"]["ship_id"]);

        -- 飞艇悬浮
        playFluctuateAnima(icon, 0.1, 1);
    elseif data.rule == "boss" then
        local monsterDisplay = createSkyBossMonster(self.info["army"][1], true);
        monsterDisplay:setScale(0.7);
        icon:addChild(monsterDisplay);
    else
        icon:setScale(0.9);
        local island, islandType = self:initIsland(data["iconName"], self.info["island_type"]);
        if not island then
            local image = ccui.ImageView:create();
            image:loadTexture(data["icon"]);
            image:setName("island");
            icon:addChild(image);
            playFluctuateAnima(icon, 1.5, 8);
        else
            icon:addChild(island);
        end

        icon:setPositionX(0);
    end

    -- 四维信息
    local ability = data.ability;

    local detailNode = findChildByName(self.node, "CT/detail_node");
    -- 火力
    local attribLabel = findChildByName(detailNode, "fire_node/attrib");
    local valueLabel = findChildByName(detailNode, "fire_node/value");

    self:setSystemTextStyle(attribLabel);
    self:setSystemTextStyle(valueLabel);

    attribLabel:setString(getLocStr("airship_fire"));
    valueLabel:setString(ability.fire);

    -- 装甲
    attribLabel = findChildByName(detailNode, "armor_node/attrib");
    valueLabel = findChildByName(detailNode, "armor_node/value");

    self:setSystemTextStyle(attribLabel);
    self:setSystemTextStyle(valueLabel);

    attribLabel:setString(getLocStr("airship_armor"));
    valueLabel:setString(ability.armor);

    -- 机动
    attribLabel = findChildByName(detailNode, "speed_node/attrib");
    valueLabel = findChildByName(detailNode, "speed_node/value");

    self:setSystemTextStyle(attribLabel);
    self:setSystemTextStyle(valueLabel);

    attribLabel:setString(getLocStr("airship_speed"));
    valueLabel:setString(ability.speed);

    -- 幸运
    attribLabel = findChildByName(detailNode, "luck_node/attrib");
    valueLabel = findChildByName(detailNode, "luck_node/value");

    self:setSystemTextStyle(attribLabel);
    self:setSystemTextStyle(valueLabel);

    attribLabel:setString(getLocStr("airship_luck"));
    valueLabel:setString(ability.luck);

    -- 总战力
    attribLabel = findChildByName(detailNode, "ability_node/attrib");
    valueLabel = findChildByName(detailNode, "ability_node/value");

    self:setSystemTextStyle(attribLabel);
    self:setSystemTextStyle(valueLabel);

    attribLabel:setString(getLocStr("fight_ability_2"));

    -- 逗号分段战力
    valueLabel:setString(thousandNum(data.fightAbility));

    -- 需要显示国籍
    local nation = findChildByName(self.node, "Top/title/nation");
    local campNode = findChildByName(detailNode, "camp_node");

    -- 非玩家
    if data.rule ~= "player" then
        nation:setVisible(false);
        campNode:setVisible(false);
        local squareNode = findChildByName(detailNode, "ability_node/square_node3");
        squareNode:setVisible(true);
    else
        local nationId = self.info["enemy"].nation or 0;
        local icon = TopM.queryNationality(nationId, "icon");
        nation:loadTexture(getNationalityIconPath(icon));
        nation:setVisible(true);

        -- 国籍位置自适应
        setNextNodePosX(titleLabel, nation, 10);

        -- 获取下国籍宽度
        local nationWidth = nation:getContentSize().width;
        titleLabel:setPositionX(titleLabel:getPositionX() + nationWidth / 2);
        nation:setPositionX(nation:getPositionX() + nationWidth / 2);


        -- 当前玩家所属阵营
        local campName = CampM.query(ability.camp, "name");
        campNode:setVisible(true);
        attribLabel = findChildByName(campNode, "attrib");
        valueLabel = findChildByName(campNode, "value");

        self:setSystemTextStyle(attribLabel);
        self:setSystemTextStyle(valueLabel);

        attribLabel:setString(getLocStr("pets_camp"));

        valueLabel:setString(campName);
    end

    -- 显示符石框
    local stoneNode = findChildByName(self.node, "BT2/stone");
    -- 没有增加的时候才增加
    if not stoneNode.iconNode then
        local itemNode = cc.CSLoader:createNode("layout/sky_city/SkyCityStoneItem.csb");
        stoneNode.iconNode = findChildByName(itemNode, "icon");
        stoneNode.iconNode:setVisible(false);
        stoneNode.bgNode = findChildByName(itemNode, "bg");
        stoneNode.hintNode = findChildByName(itemNode, "hint");

        itemNode:setScale(0.8);
        stoneNode:addChild(itemNode);

        -- 显示泡泡
        stoneNode.hintNode:setVisible(true);
        playCanEquipHintEffect(stoneNode.hintNode, 0, 0);
    end


    self:redrawDesc();

    -- 绘制奖励
    self:redrawBonus();
end

-- 更新符石图标
function UISkyCityIslandInfo:updateStone(stoneClassId)
    self.stoneClassId = stoneClassId;

    local stoneNode = findChildByName(self.node, "BT2/stone");
    local iconName = ItemM.query(stoneClassId, "icon");
    stoneNode.iconNode:setVisible(true);
    stoneNode.iconNode:loadTexture(getItemIconPath(iconName));
    stoneNode.hintNode:setVisible(false);
end

-- 清空所有的奖励格
function UISkyCityIslandInfo:clearAllGrid()
    self.scrollView.rows = {};
    self.scrollView:removeAllChildren();
end

-- 绘制奖励
function UISkyCityIslandInfo:redrawBonus()
    local bonusNode = findChildByName(self.node, "BT2/desc_node/bonus_node");
    bonusNode:setVisible(true);
    local panel = findChildByName(bonusNode, "bonus_panel");

    -- 收集信息
    local goodsList = self.data["bonus"] or {};
    local totalGridCount = #goodsList;

    if not goodsList or #goodsList == 0 then
        cclog("收集信息失败。");
        self:clearAllGrid();
        return;
    end

    if totalGridCount < 4 then
        totalGridCount = 4
    end

    -- 初始化格子
    self:initGrids(totalGridCount);

    -- 显示奖励信息
    local totalGoodsCount = #goodsList;
    for i = 1, totalGridCount do
        local grid          = self.scrollView:getChildByName("item" .. i);
        local goodsBg       = grid:getChildByName("bg");
        local buyImg        = grid:getChildByName("buy");
        local starNode      = grid:getChildByName("stars");
        local numLabel      = grid:getChildByName("num_label");
        local countLabel    = grid:getChildByName("num");
        local iconImg       = grid:getChildByName("icon");

        countLabel:setVisible(true);
        numLabel:setVisible(false);
        buyImg:setVisible(false);

        if i <= totalGoodsCount and type(goodsList[i]) == "table" then
            grid:setVisible(true);

            local classId = goodsList[i]["class_id"];
            local count   = goodsList[i]["count"] or 0;

            -- 显示数量
            TextStyleM.setTextStyle(countLabel, TextStyleM.TEXT_SIZE_SMALL2, TextStyleM.TEXT_COLOR_BROWN_YELLOW, true, -2);
            if count > 1 then
                -- 需要显示数量
                countLabel:setString(changeNumType(count));
            else
                countLabel:setVisible(false);
            end

            -- 显示商品图标
            local goodsIcon;
            local para;
            if type(classId) == "number" then
                goodsIcon = getItemIconPath(ItemM.query(classId, "icon"));
            else
                goodsIcon = getItemIconPath(goodsList[i]["icon"]);
                para = goodsList[i];
            end

            iconImg:loadTexture(goodsIcon);

            -- 注册点击事件
            self:clickShowDesc(grid, goodsList[i], para);
        else
            -- 多余格子置灰白
            iconImg:setVisible(false);
            setGrayTransMode(goodsBg, true);
        end
    end
end

-- 初始化奖励格子
function UISkyCityIslandInfo:initGrids(gridCount)
    local w = DESIGN_WIDTH;
    local h = DESIGN_HEIGHT;

    -- 图标间距(横向)
    local wGap = -5;

    -- 图标间距(纵向)
    local hGap = 10;

    -- 图标宽度
    local iconWidth = 127;

    -- 图片高度
    local iconHeight = 110;

    local topHGap  = 10;
    local bottomHGap  = 0;
    local leftWGap = 5;

    -- 总数
    local totalCount = gridCount;

    self.scrollView.rows = {};
    self.scrollView:removeAllChildren();

    local itemNode = cc.CSLoader:createNode("layout/sky_city/SkyStoreItem.csb");
    -- @param windowNode    界面节点
    -- @param scrollNode    容器节点
    -- @param itemNode      单元格的节点
    -- @param totalNum      单元格总数
    -- @param maxRowNum     最大行数
    -- @param pageColNum    单页可以显示下的列数
    -- @param wGap          单元格间距(横向) 这里作为最小值使用
    -- @param hGap          单元格间距(纵向)
    -- @param iconWidth     单元格宽度
    -- @param iconHeight    单元格高度
    -- @param topHGap       上方留白
    -- @param leftWGap      左右留白  这里作为最小值使用
    -- @param touchEvent    点击事件注册函数
    -- @param initHandle    格子初始化委托
    -- @param schedulerId   定时器id
    initScrollGridsVertical(self, self.scrollView, itemNode,
        totalCount, MAX_GRID_ROW, MIN_GRID_COLUMN, wGap, hGap,
        iconWidth, iconHeight, topHGap, bottomHGap, leftWGap);

    for _, child in ipairs(self.scrollView.rows) do
        child:setScale(0.88);
    end
end

-- 点击图标处理
function UISkyCityIslandInfo:clickShowDesc(node, bonus, para)
    -- 点击处理
    local bg = findChildByName(node, "bg");
    bg:setTouchEnabled(true);
    bg:addTouchEventListener(function(sender, eventType)
        if eventType == ccui.TouchEventType.ended then
            AudioM.playFx("workshop_material");
            UIMgr:getCurrentScene():removeFormByName("UIItemDesc");
            if type(bonus["class_id"]) == "number" then
                -- 显示道具详细信息
                local uiItemDesc = UIItemDesc.create(bonus["class_id"], nil, para);
                UIMgr:getCurrentScene():addForm(uiItemDesc);
            else
                -- 显示奖励描述信息
                local uiItemDesc = UIItemDesc.create(bonus["id"], nil, para);
                UIMgr:getCurrentScene():addForm(uiItemDesc);
            end
        end
    end);
end


-- 注册事件处理回调函数
function UISkyCityIslandInfo:registerEventCallback()
    -- 界面析构后，需要清理下
    self:registerScriptHandler(function(eventType)
        if eventType == "exit" then
            EventMgr.removeAll("UISkyCityIslandInfo");
            local uiForm = UIMgr.getCurrentScene():getFormByName("UISkyCity");
            if uiForm then
                uiForm:showInfoNode(true);
            end
        elseif eventType == "enter" then
            local uiForm = UIMgr.getCurrentScene():getFormByName("UISkyCity");
            if uiForm then
                uiForm:showInfoNode(false);
            end
        end
    end);

    -- 注册获得焦点的回调
    EventMgr.register("UISkyCityIslandInfo", event.FOCUS_CHANGED, function(para)
        -- TODO
        if para["get"] == "UISkyCityIslandInfo" then

        elseif para["lose"] == "UISkyCityIslandInfo" then

        end
    end);
end

-- 注册点击事件
function UISkyCityIslandInfo:registerTouchEvent()
    -- 注册返回按钮点击事件
    local btnBack = findChildByName(self.node, "BT/btn_back");
    local function onBackClick(sender, eventType)
        if eventType == ccui.TouchEventType.ended then
            -- 关闭当前界面
            AudioM.playFx("ship_return");
            UIMgr.getCurrentScene():removeFormByName("UISkyCityIslandInfo");
        end
    end
    AddBackEventHandler(self, btnBack, onBackClick);
    TextStyleM.setTextStyle(btnBack, TextStyleM.TEXT_SIZE_MIDDLE, TextStyleM.TEXT_COLOR_BROWN_YELLOW, true);
    btnBack:setTitleText(getLocStr("btn_text_back"));

    -- 隐藏建造/出战/翻页按钮
    local btnMake = findChildByName(self.node, "BT/btn_make");
    local btnActived = findChildByName(self.node, "BT/btn_actived");
    local btnNext = findChildByName(self.node, "CT/btn_next");
    local btnLast = findChildByName(self.node, "CT/btn_last");
    local hideNodes = {btnMake, btnActived, btnNext, btnLast};
    for _, node in pairs(hideNodes) do
        node:setVisible(false);
    end

    -- 袭击说明按钮点击事件
    local btnAttack = findChildByName(self.node, "BT/btn_make");
    local function onAttackClick(sender, eventType)
        if eventType == ccui.TouchEventType.ended then
            AudioM.playFx("ship_click");

            local uiSkyCity  = UIMgr.getCurrentScene():getFormByName("UISkyCity");
            uiSkyCity:doEvent(self.info["pos"], {["stone_id"] = self.stoneClassId});

            UIMgr.getCurrentScene():removeFormByName("UISkyCityIslandInfo");
        end
    end
    btnAttack:addTouchEventListener(onAttackClick);
    TextStyleM.setTextStyle(btnAttack, TextStyleM.TEXT_SIZE_MIDDLE, TextStyleM.TEXT_COLOR_BROWN_YELLOW, true);
    btnAttack:setTitleText(getLocStr("btn_text_attack"));
    btnAttack:setVisible(true);

    -- 符石框点击处理
    local stoneNode = findChildByName(self.node, "BT2/stone");
    stoneNode.bgNode:setTouchEnabled(true);
    local function onStoneImgClick(sender, eventType)
        if eventType == ccui.TouchEventType.ended then
            -- 打开符石选择框
            require "game/ui/form/sky_city/UISkyStoneChoose";

            UIMgr.getCurrentScene():removeFormByName("UISkyStoneChoose");
            local uiForm = UISkyStoneChoose.create("explore", self);
            UIMgr.getCurrentScene():addForm(uiForm);
        end
    end
    stoneNode.bgNode:addTouchEventListener(onStoneImgClick);
end

-- 设置信息的字体
function UISkyCityIslandInfo:setSystemTextStyle(textLabel)
    textLabel:setFontSize(TextStyleM.TEXT_SIZE_TINY + 2);
    textLabel:setTextColor(TextStyleM.TEXT_COLOR_BRIGHT_BLUE);
    -- TextStyleM.setOutlineStyle(textLabel, 2, TextStyleM.TEXT_COLOR_DARK_BLUE2, true);

    textLabel:setScale(0.85);
end

-- 根据当前抽取到的类型，重绘描述信息
function UISkyCityIslandInfo:redrawDesc()
    local descNode = findChildByName(self.node, "BT2/desc_node");
    local titleLabel = findChildByName(descNode, "title_label");
    local descLabel = findChildByName(descNode, "desc_label");

    -- 根据规则获得当前描述
    local info = table.deepcopy(self.info);
    local eventId = info.id;
    local titleName = SkyExploreM.query(eventId, "name");
    local rule = SkyExploreM.query(eventId, "rule");
    if rule == "player" then
        titleName = NewAirShipM.query(info["enemy"].ship_id, "name");
    end
    local descStr = self:getDesc(eventId, rule);

    titleName = string.format(getLocStr("special_skill_name_format"), titleName, info.explore_level);

    local lineCount = 4;
    local fontSize = TextStyleM.TEXT_SIZE_SMALL;
    if isFullWidthLang() then
        lineCount = 3;
    elseif getLang() == "th" then
        lineCount = 1.4;
        fontSize = TextStyleM.TEXT_SIZE_MINI;
    end
    local textScale = TextStyleM.getTextScale(descStr, 19 * 2 * lineCount);
    TextStyleM.setTextStyle(titleLabel, TextStyleM.TEXT_SIZE_MIDDLE, TextStyleM.TEXT_COLOR_DARK_RED);
    TextStyleM.setTextStyle(descLabel, fontSize, TextStyleM.TEXT_COLOR_DARK_BROWN, nil, nil, nil, nil, nil, nil, nil, textScale);

    titleLabel:setString(titleName);
    descLabel:setString(descStr);
end

-- 获得当前浮岛的描述
function UISkyCityIslandInfo:getDesc(eventId, rule)
    -- 如果该浮岛配置了描述，优先使用；否则根据类型给出描述
    local islandDesc = SkyExploreM.query(eventId, "island_desc");
    if type(islandDesc) == "string" and #islandDesc > 0 then
        return islandDesc;
    end

    if rule == "resource" then
        return getLocStr("sky_resource_island_desc");
    elseif rule == "monster" then
        return getLocStr("sky_monster_island_desc");
    elseif rule == "boss" then
        return getLocStr("sky_boss_island_desc");
    elseif rule == "player" then
        return getLocStr("sky_player_island_desc");
    else
        return "";
    end
end

-- 初始化浮岛
function UISkyCityIslandInfo:initIsland(name, islandType)
    -- TODO:考虑进入游戏时，一次性缓存所有浮岛
    -- 获取浮岛节点
    local islandNode = cc.CSLoader:createNode("layout/sky_city/skyIslandTemplate.csb");
    local widget = replaceNodeWithWidget(islandNode);
    local child = widget:clone();
    child:setName("island");

    -- 获取配置
    local configs, islandType = SkyIslandM.initIslandByName(name, islandType);
    if not configs or type(configs) ~= "table" or #configs == 0 then
        return nil;
    end

    -- 生成浮岛
    for _, config in pairs(configs) do
        local node = findChildByName(child, config["node"]);
        node:setVisible(true);
        node:loadTexture(getskyIslandIconPath(config["icon"]), 1);

        -- 偏移微调
        local offset = config["offset"];
        node:setPosition(node:getPositionX() + offset[1], node:getPositionY() + offset[2]);

        -- 缩放调整
        local scale = config["scale"];
        if type(scale) == "number" then
            node:setScale(scale / 1000);
        end

        -- 缩放透明度
        local opacity = config["opacity"];
        if type(opacity) == "number" then
            node:setOpacity(opacity / 1000 * 255);
        end

        -- 根据层级相对位移
        local layer = config["layer"];
        performWithDelay(node, function()
            playFluctuateAnima(node, 1.5, 8);
        end, layer - 0.5);
    end

    return child, islandType;
end

-- 从中间浮现效果
function UISkyCityIslandInfo:comformCenterEffect()
    local BT2 = findChildByName(self.node, "BT2");
    local Top = findChildByName(self.node, "Top");
    if not BT2 or not Top then
        return;
    end

    local titleNode = findChildByName(Top, "title");
    local descNode = findChildByName(BT2, "desc_node");

    local oldScale = titleNode:getScale();
    local descSale = descNode:getScale();

    -- title
    titleNode:setScale(oldScale * 0.8);
    local scaleUp1 = cc.EaseIn:create(cc.ScaleTo:create(0.2, oldScale * 1.05), 0.4);
    local scaleUp2 = cc.ScaleTo:create(0.05, oldScale);
    titleNode:runAction(cc.Sequence:create(scaleUp1, scaleUp2));

    descNode:setScale(descSale * 0.8);
    local scaleUp3 = cc.EaseIn:create(cc.ScaleTo:create(0.2, descSale * 1.05), 0.4);
    local scaleUp4 = cc.ScaleTo:create(0.05, descSale);
    descNode:runAction(cc.Sequence:create(scaleUp3, scaleUp4));
end
